#include "requestmanager.h"

RequestManager::RequestManager(QObject *parent) :
    QObject(parent)
{
    urlReq = "http://eu.battle.net/api/wow/spell/8056?";
    localeReq  = "locale=ru_RU";
    QNetworkAccessManager* nam = new QNetworkAccessManager;
    QObject::connect(nam, &QNetworkAccessManager::finished,
                     [=] ()
    {
        requestRes(reply);
    });



    QUrl url();
    reply = nam->get(QNetworkRequest(url));
}

void RequestManager::requestRes(QNetworkReply *reply)
{

    if (reply->error() == QNetworkReply::NoError)
    {
        QByteArray bytes = reply->readAll();  // bytes
        qDebug()<<"rm>> "<<bytes;
        emit requestResult( &bytes ) ;

    }
    else
    {

    }

    delete reply;
}
